#include"mylist.h"


/*1 2 3
[0]->[3]->[2]->[1]
*/
void createList2(node **head)
{
  int value;
 node *temp,*p;
 if (*head == NULL)
 {
  temp = (node *)calloc(sizeof(node),1);
  temp->data = 0;
  temp->next = NULL;
  *head = temp;
 }
 p =*head;
 
 printf("input value\n");
 scanf("%d",&value);
 
 while ( value != -1 )
 {
  temp = (node *)calloc(sizeof(node),1);
  temp->data = value;
  temp->next = NULL;
  p->next = temp;
  p = temp;
  printf("input value\n");
  scanf("%d",&value);
 }

 }
void createList(node **head)
{
 int value;
 node *temp;
 if (*head == NULL)
 {
  temp = (node *)calloc(sizeof(node),1);
  temp->data = 0;
  temp->next = NULL;
  *head = temp;
 }
 printf("input value\n");
 scanf("%d",&value);

 while ( value != -1 )
 {
  
  temp = (node *)calloc(sizeof(node),1);
  temp->data = value;
  temp->next = (*head)->next;
  (*head)->next = temp;

  printf("input value\n");
  scanf("%d",&value);
 }
}

void printList(node *head)
{
 	 if (head == NULL || head->next == NULL)
 	 	 return;
 	  head = head->next;
	  while(head != NULL)
 	 {
	  			printf("%d\n",head->data);
	  			head = head->next;
	  			}
 }
